<?php


namespace app\api\controller;
use app\api\model\Movie as MovieModel;

class Movie extends Controller
{
    public function getList(){
        $model=new MovieModel();
        $news=$model->select();
        return $this->renderSuccess($news,'获取列表成功');

    }

    public function index($movieid,$uid,$type){
        $model=new MovieModel();
        $movie=$model->where(['uid'=>$uid,'movieid'=>$movieid,'type'=>$type])->select();
        if(!empty($movie)){
        return $this->renderSuccess(['choose'=>false],'已存在想看');}
        else{return $this->renderSuccess(['choose'=>true],'不存在想看');}
    }
public function addWatch($movieid,$uid,$type)
{
    $model = new MovieModel();
    $movie = $model->where(['uid' => $uid, 'movieid' => $movieid,'type'=>$type])->select();
    if (empty($movie)) {
        $model->save($this->request->param());
        return $this->renderSuccess(['choose' => false], '添加成功');
    } else {
        $model->where(['uid' => $uid, 'movieid' => $movieid,'type'=>$type])->delete();
        return $this->renderSuccess(['choose' => true],'已存在');

    }
}
public function Watch($uid,$type){
    $model=new MovieModel();
    $movie=$model->where(['uid'=>$uid,'type'=>$type])->select();
    return $this->renderSuccess($movie,'想看/收藏');
}

}
